﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UriTest.cs" company="Believe">
//   WhenYouBelieve2014@gmail.com
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace TestProject
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using UriCombine;

    /// <summary>
    ///     The uri test.
    /// </summary>
    [TestClass]
    public class UriTest
    {
        #region Public Methods and Operators

        /// <summary>
        ///     The combine test.
        /// </summary>
        [TestMethod]
        public void CombineTest_WhenFirstPartContainsVirtualPath_ShouldReturnValidUrl()
        {
            string actual = Uri.Combine("https://www.google.com/some", "file.doc");
            const string EXPECTED = "https://www.google.com/some/file.doc";
            Assert.AreEqual(EXPECTED, actual);
        }

        /// <summary>
        ///     The combine test.
        /// </summary>
        [TestMethod]
        public void CombineTest_WhenPartsAreRelativePaths_ShouldReturnValidUrl()
        {
            string actual = Uri.Combine("some", "file.doc");
            const string EXPECTED = "some/file.doc";
            Assert.AreEqual(EXPECTED, actual);
        }

        /// <summary>
        ///     The combine test.
        /// </summary>
        [TestMethod]
        public void CombineTest_WhenPassing2Parts_ShouldReturnValidUrl()
        {
            string actual = Uri.Combine("https://www.google.com", "some");
            const string EXPECTED = "https://www.google.com/some";
            Assert.AreEqual(EXPECTED, actual);
        }

        /// <summary>
        ///     The combine test.
        /// </summary>
        [TestMethod]
        public void CombineTest_WhenPassing3Parts_ShouldReturnValidUrl()
        {
            string actual = Uri.Combine("https://www.google.com", "some", "file.doc");
            const string EXPECTED = "https://www.google.com/some/file.doc";
            Assert.AreEqual(EXPECTED, actual);
        }

        /// <summary>
        ///     The FTP combine test.
        /// </summary>
        /// <remarks>
        /// http://stackoverflow.com/a/23458146/3481183
        /// </remarks>
        [TestMethod]
        public void CombineTest_WhenCombiningFtpParts_ShouldReturnValidUrl()
        {
            string actual = Uri.Combine("ftp://my|user|name:mypassword@example.com", "some", "file.doc");
            const string EXPECTED = "ftp://my|user|name:mypassword@example.com/some/file.doc";
            Assert.AreEqual(EXPECTED, actual);
        }

        #endregion
    }
}